// test1.ts

// 函数1：无参数传入传出，for循环1加到1000赋值数组2，作为baseline
export function baselineTest(): void {
    let array2: Array<i32> = new Array<i32>(100000);
    for (let i = 0; i < 100000; i++) {
        array2[i] = i + 1;
    }
}

// 函数2：无参数传入，for循环1到1000赋值给数组2，传出数组2 
export function noInputWithOutput(): Array<i32> {
    let array2: Array<i32> = new Array<i32>(100000);
    for (let i = 0; i < 100000; i++) {
        array2[i] = i + 1;
    }
    return array2;
}

// 函数3：传入数组1，for循环1到1000赋值给数组2，这一步目的是控制变量，传出数组2
export function withInputAndOutput(array1: Array<i32>): Array<i32> {
    //console.log(`First element of array1: ${array1[0]}, Last element of array1: ${array1[array1.length - 1]}`);
    let sum = array1[3];
    let array2: Array<i32> = new Array<i32>(100000);

    for (let i = 0; i < 100000; i++) {
        array2[i] = i + 1;
        //sum = sum + array1[i];
    }
    return array2;
}

// 函数4：传入数组1，for循环1到1000赋值给数组2，这一步目的是控制变量，无返回值
export function withInputNoOutput(array1: Array<i32>): void {
    let sum = array1[3];
    let array2: Array<i32> = new Array<i32>(100000);
    for (let i = 0; i < 100000; i++) {
        array2[i] = i + 1;
        //array2[i] = array1[i] 
    }

}